package com.gang.mars.basic.generictype.demo8;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @Author：gang.chen
 * @Date：2023/6/13 13:52
 */
public class example2 <T>{

    private Random random = new Random();

    private T product;

    private List<T> products = new ArrayList<>();

    public void addProduct(T product)
    {
        this.products.add(product);
    }

    public T getRandomPrize()
    {
        int i = random.nextInt(this.products.size());
        return products.get(i);
    }

    public T getProduct() {
        return product;
    }

    public void setProduct(T product) {
        this.product = product;
    }

    public List<T> getProducts() {
        return products;
    }

    public void setProducts(List<T> products) {
        this.products = products;
    }
}
